package nku.csc360;

//Raj Akula
import java.util.*;
public class Problem1 {
	
	public static void main(String... Args){
		
		Set<String> set1 = new HashSet<String>();
    	Set<String> set2 = new HashSet<String>();
    	Set<String> union = new HashSet<String>();
    	Set<String> difference = new HashSet<String>();
    	Set<String> intersection = new HashSet<String>();
    	Set<String> dups    = new HashSet<String>();
    	
    	set1.add("George");
    	set1.add("Jim");
   		set1.add("John");
   		set1.add("Blake");
    	set1.add("Kevin");
   		set1.add("Micheal"); 
    	set2.add("George");
    	set2.add("Katie");
   		set2.add("Kevin");
   		set2.add("Michelle");
   		set2.add("Ryan");
	
		//Before Set1 With Iterator
		System.out.print("Set1 Before W/ Iternator :");
		Iterator<String> i = set1.iterator();
    	while (i.hasNext()) {
    		String c = i.next();
	    	System.out.print(c + " ");
    	}
    	System.out.println();
    	
    	//Before Set2 With Iterator
    	System.out.print("Set2 Before W/ Iternator :");
		Iterator<String> j = set2.iterator();
    	while (j.hasNext()) {
    		String c = j.next();
	    	System.out.print(c + " ");
    	}
    	System.out.println();
    	
    	//Union Difference Intersection
    	union.addAll(set1);
    	union.addAll(set2);
    	intersection.addAll(set1);
    	intersection.addAll(set2);
    	
    	//Union
    	System.out.print("Union :");
		i = union.iterator();
    	while (i.hasNext()) {
    		String c = i.next();
	    	System.out.print(c + " ");
    	}
    	System.out.println();
    	
    	//Intersection and Differences
    	difference.addAll(set1);
    	for (String a : set2)
            if (!difference.add(a))
                dups.add(a);
        intersection.removeAll(dups);
        System.out.print("Intersection :");
		i = dups.iterator();
    	while (i.hasNext()) {
    		String c = i.next();
	    	System.out.print(c + " ");
    	}
    	System.out.println();
    	
    	System.out.print("Differences: ");
		i = difference.iterator();
    	while (i.hasNext()) {
    		String c = i.next();
	    	System.out.print(c + " ");
    	}
    	System.out.println();
    	
    	

    	//After Set1 W/ Iterator
    	System.out.print("Set1 After W/ Iternator :");
		i = set1.iterator();
    	while (i.hasNext()) {
    		String c = i.next();
	    	System.out.print(c + " ");
    	}
    	System.out.println();
    	
    	//After Set2 W/ Iterator
    	System.out.print("Set2 After W/ Iternator :");
		j = set2.iterator();
    	while (j.hasNext()) {
    		String c = j.next();
	    	System.out.print(c + " ");
    	}
    	
		
	}
	
    
    
}